package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.SignStore;
import cn.wolfcode.trip.base.mapper.SignStoreMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ISignStoreService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SignStoreServiceImpl implements ISignStoreService {

    @Autowired
    SignStoreMapper storeMapper;


    public List<SignStore> selectAll() {
        return null;
    }

    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize(), qo.getOrderBy());
        List<SignStore> list = storeMapper.selectForList(qo);
        return new PageInfo(list);
    }

    public SignStore selectOne(SignStore record) {
        return storeMapper.selectByPrimaryKey(record.getId());
    }


    //添加或修改
    public void saveOrUpdate(SignStore entity) {
        if (entity.getId() != null) {
            //修改
            storeMapper.updateByPrimaryKey(entity);
        } else {
            //新增
            storeMapper.insert(entity);
        }
    }

    //删除一条商品信息
    public void delete(Long id) {
        storeMapper.deleteByPrimaryKey(id);

    }

    public List<SignStore> selectProducts(Long userId) {
        List<SignStore> signStores = storeMapper.selectByUserId(userId);
        return signStores;
    }


}
